//
//  FRQMyDeviceViewController.m
//  FRQBluetoothKit_Example
//
//  Created by admin on 2023/10/23.
//  Copyright © 2023 xuchunhai. All rights reserved.
//

#import "FRQMyDeviceViewController.h"
#import "FRQForgetDeviceViewController.h"
#import "MyDeviceViews.h"
#import "FRQDevicePairViewController.h"
#import "FRQForgetDeviceViewController.h"
#import "FRQViewController.h"
#import "FRQFeedbackViewController.h"
@interface FRQMyDeviceViewController ()
@property (nonatomic,strong) MyDeviceViews *MyDeviceView;
@end

@implementation FRQMyDeviceViewController

-(MyDeviceViews *)MyDeviceView{
    if (nil==_MyDeviceView) {
        _MyDeviceView=skXibView(@"MyDeviceViews");
        [self.view addSubview:_MyDeviceView];
        [_MyDeviceView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_topLayoutGuide);
            make.bottom.mas_equalTo(self.mas_bottomLayoutGuide);
            make.right.left.mas_equalTo(0);
        }];
        @weakify(self)
        [[_MyDeviceView.btnForget rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            
//            FRQFeedbackViewController *view=[[FRQFeedbackViewController alloc] init];
//            [self presentViewController:view animated:YES completion:^{
//
//            }];
            
            FRQForgetDeviceViewController *view=[[FRQForgetDeviceViewController alloc] init];
            view.viewType=0;
            view.devNo=skDevice.devNo;
            view.modalPresentationStyle=0;
            view.bvalCount = 1;
            [self presentViewController:view animated:YES completion:^{

            }];
            
        }];
    }
    return _MyDeviceView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"My Device";
    [self MyDeviceView];
    // Do any additional setup after loading the view.
    [self appDeviceMine];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pairBackAction) name:@"PairBack" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(kefuBackAction) name:@"KefuBack" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contactUsAction) name:@"ContactUs" object:nil];
}
- (void)pairBackAction{
    FRQViewController *view=[[FRQViewController alloc] init];
    view.typeShow=0;
    view.modalPresentationStyle=0;
    view.bvalCount = 1;
    [self presentViewController:view animated:YES completion:^{
        
    }];
}
- (void)kefuBackAction{
    FRQContactUsViewController *view=[[FRQContactUsViewController alloc] init];
    view.modalPresentationStyle=0;
    view.bvalCount = 1;
    [self presentViewController:view animated:YES completion:^{
        
    }];
}
- (void)contactUsAction{
    FRQForgetDeviceViewController *view=[[FRQForgetDeviceViewController alloc] init];
    view.viewType=1;
    view.devNo=skDevice.devNo;
    view.modalPresentationStyle=0;
    view.bvalCount = 1;
    [self presentViewController:view animated:YES completion:^{
        
    }];
}
-(void)appDeviceMine{
    
    NSDictionary *dic=@{};
    [skNetTools skGETWithURL:[NSString stringWithFormat:@"%@%@",skURL,@"app/device/mine"] parameters:dic cachePolicy:0 callback:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        NSLog(@"数据=%@",responseObject);
        skNetModel *model=[skNetModel mj_objectWithKeyValues:responseObject];
        if(model.code==200){
            [MineDeviceInfoModel mj_objectWithKeyValues:model.data];
            
            _MyDeviceView.txtDeviceInfo.text=skDevice.devNo;
        }else{
            [SkToast SkToastShow:model.msg];
        }
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
